package com.kang.commons.util;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;

/**
 * 加解密工具类
 */
public class EncryptUtil {

    private static final StandardPBEStringEncryptor ENCRYPTOR =
            new StandardPBEStringEncryptor();
    static {
        EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
        //加密算法
        config.setAlgorithm("PBEWithMD5AndDES");
        //salt
        config.setPassword("Et2009@?");
        ENCRYPTOR.setConfig(config);
    }
    /** 加密方法 */
    public static String encrypt(String plainText){
        return ENCRYPTOR.encrypt(plainText);
    }

    /** 解密方法 */
    public static String decrypt(String cipher){
        return ENCRYPTOR.decrypt(cipher);
    }

}
